from django.template.loader import get_template
from django.template import Template, Context
from django.shortcuts import render
from django.http import HttpResponse
import datetime

def root(request):
    return HttpResponse("This is a rooot!")

def hello(request):
    return HttpResponse("Hello")

def current_datetime(request):
    now = datetime.datetime.now()
    return render(request, 'dateapp/current_datetime.html', {'current_date': now})

def hours_ahead(request, offset):
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()
    now = datetime.datetime.now() + datetime.timedelta(hours=offset)
    return render(request, 'dateapp/future_datetime.html', {'hour_offset': offset, 'next_time': now})
